/**
 * Export Task API Service  
 * 数据字典导出API服务 (FR-013 ~ FR-015)
 */

import { get, post } from './client'
import type { ApiResponse, PageResponse, ExportTask, ExportTaskCreateRequest } from '../models/types'

export const listExportTasks = async (params: any): Promise<ApiResponse<PageResponse<ExportTask>>> => {
  return get<PageResponse<ExportTask>>('/exports', { params })
}

export const createExportTask = async (data: ExportTaskCreateRequest): Promise<ApiResponse<ExportTask>> => {
  return post<ExportTask>('/exports', data)
}

export const downloadExportFile = async (id: number): Promise<Blob> => {
  const response = await get<Blob>(`/exports/${id}/download`, { responseType: 'blob' })
  return response.data!
}

export const retryArchive = async (id: number): Promise<ApiResponse<void>> => {
  return post<void>(`/exports/${id}/archive`, {})
}
